package qldc.pm.tiensu.service.persistence;

import com.liferay.portal.kernel.cache.CacheRegistryUtil;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.InstanceFactory;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.UnmodifiableList;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.ModelListener;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;

import qldc.pm.tiensu.NoSuchYeuCauTrichLucException;
import qldc.pm.tiensu.model.YeuCauTrichLuc;
import qldc.pm.tiensu.model.impl.YeuCauTrichLucImpl;
import qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl;
import qldc.pm.tiensu.service.persistence.YeuCauTrichLucPersistence;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The persistence implementation for the yeu cau trich luc service.
 *
 * <p>
 * Caching information and settings can be found in <code>portal.properties</code>
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see YeuCauTrichLucPersistence
 * @see YeuCauTrichLucUtil
 * @generated
 */
public class YeuCauTrichLucPersistenceImpl extends BasePersistenceImpl<YeuCauTrichLuc>
    implements YeuCauTrichLucPersistence {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. Always use {@link YeuCauTrichLucUtil} to access the yeu cau trich luc persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
     */
    public static final String FINDER_CLASS_NAME_ENTITY = YeuCauTrichLucImpl.class.getName();
    public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
        ".List1";
    public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
        ".List2";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
            "findAll", new String[0]);
    public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
    public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED, Long.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
    public static final FinderPath FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC = new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, FINDER_CLASS_NAME_ENTITY,
            "fetchBySoCMNDDoiTuongTrichLuc",
            new String[] { String.class.getName() },
            YeuCauTrichLucModelImpl.SOCMNDDOITUONGTRICHLUC_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC = new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED, Long.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countBySoCMNDDoiTuongTrichLuc",
            new String[] { String.class.getName() });
    private static final String _FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc IS NULL";
    private static final String _FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc = ?";
    private static final String _FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soCMNDDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soCMNDDoiTuongTrichLuc = '')";
    public static final FinderPath FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, FINDER_CLASS_NAME_ENTITY,
            "fetchBySoDinhDanhCaNhanDoiTuongTrichLuc",
            new String[] { String.class.getName() },
            YeuCauTrichLucModelImpl.SODINHDANHCANHANDOITUONGTRICHLUC_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED, Long.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countBySoDinhDanhCaNhanDoiTuongTrichLuc",
            new String[] { String.class.getName() });
    private static final String _FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc IS NULL";
    private static final String _FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc = ?";
    private static final String _FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc = '')";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
            "findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK",
            new String[] {
                String.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName(),
                String.class.getName(),
                
            Integer.class.getName(), Integer.class.getName(),
                OrderByComparator.class.getName()
            });
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED, Long.class,
            FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
            "countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK",
            new String[] {
                String.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName(),
                String.class.getName()
            });
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_1 =
        "yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_2 =
        "yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_3 =
        "(yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc IS NULL OR yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soCMNDDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE NULL";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE ?";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE '')";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
            "findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI",
            new String[] {
                Boolean.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName(),
                
            Integer.class.getName(), Integer.class.getName(),
                OrderByComparator.class.getName()
            });
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI =
        new FinderPath(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucModelImpl.FINDER_CACHE_ENABLED, Long.class,
            FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
            "countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI",
            new String[] {
                Boolean.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName(),
                String.class.getName(), String.class.getName()
            });
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_DATRICHLUC_2 =
        "yeuCauTrichLuc.daTrichLuc = ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soDinhDanhCaNhanDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_1 =
        "yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_2 =
        "yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_3 =
        "(yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc IS NULL OR yeuCauTrichLuc.hoVaTenNguoiYeuCauTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soCMNDDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soCMNDDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE NULL AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE ? AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.hoVaTenDoiTuongTrichLuc LIKE '') AND ";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_1 =
        "yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE NULL";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_2 =
        "yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE ?";
    private static final String _FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_3 =
        "(yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc IS NULL OR yeuCauTrichLuc.soSoHoKhauDoiTuongTrichLuc LIKE '')";
    private static final String _SQL_SELECT_YEUCAUTRICHLUC = "SELECT yeuCauTrichLuc FROM YeuCauTrichLuc yeuCauTrichLuc";
    private static final String _SQL_SELECT_YEUCAUTRICHLUC_WHERE = "SELECT yeuCauTrichLuc FROM YeuCauTrichLuc yeuCauTrichLuc WHERE ";
    private static final String _SQL_COUNT_YEUCAUTRICHLUC = "SELECT COUNT(yeuCauTrichLuc) FROM YeuCauTrichLuc yeuCauTrichLuc";
    private static final String _SQL_COUNT_YEUCAUTRICHLUC_WHERE = "SELECT COUNT(yeuCauTrichLuc) FROM YeuCauTrichLuc yeuCauTrichLuc WHERE ";
    private static final String _ORDER_BY_ENTITY_ALIAS = "yeuCauTrichLuc.";
    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No YeuCauTrichLuc exists with the primary key ";
    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No YeuCauTrichLuc exists with the key {";
    private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get(
                PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
    private static Log _log = LogFactoryUtil.getLog(YeuCauTrichLucPersistenceImpl.class);
    private static YeuCauTrichLuc _nullYeuCauTrichLuc = new YeuCauTrichLucImpl() {
            @Override
            public Object clone() {
                return this;
            }

            @Override
            public CacheModel<YeuCauTrichLuc> toCacheModel() {
                return _nullYeuCauTrichLucCacheModel;
            }
        };

    private static CacheModel<YeuCauTrichLuc> _nullYeuCauTrichLucCacheModel = new CacheModel<YeuCauTrichLuc>() {
            @Override
            public YeuCauTrichLuc toEntityModel() {
                return _nullYeuCauTrichLuc;
            }
        };

    public YeuCauTrichLucPersistenceImpl() {
        setModelClass(YeuCauTrichLuc.class);
    }

    /**
     * Returns the yeu cau trich luc where soCMNDDoiTuongTrichLuc = &#63; or throws a {@link qldc.pm.tiensu.NoSuchYeuCauTrichLucException} if it could not be found.
     *
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @return the matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySoCMNDDoiTuongTrichLuc(
        String soCMNDDoiTuongTrichLuc)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySoCMNDDoiTuongTrichLuc(soCMNDDoiTuongTrichLuc);

        if (yeuCauTrichLuc == null) {
            StringBundler msg = new StringBundler(4);

            msg.append(_NO_SUCH_ENTITY_WITH_KEY);

            msg.append("soCMNDDoiTuongTrichLuc=");
            msg.append(soCMNDDoiTuongTrichLuc);

            msg.append(StringPool.CLOSE_CURLY_BRACE);

            if (_log.isWarnEnabled()) {
                _log.warn(msg.toString());
            }

            throw new NoSuchYeuCauTrichLucException(msg.toString());
        }

        return yeuCauTrichLuc;
    }

    /**
     * Returns the yeu cau trich luc where soCMNDDoiTuongTrichLuc = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
     *
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @return the matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySoCMNDDoiTuongTrichLuc(
        String soCMNDDoiTuongTrichLuc) throws SystemException {
        return fetchBySoCMNDDoiTuongTrichLuc(soCMNDDoiTuongTrichLuc, true);
    }

    /**
     * Returns the yeu cau trich luc where soCMNDDoiTuongTrichLuc = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
     *
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param retrieveFromCache whether to use the finder cache
     * @return the matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySoCMNDDoiTuongTrichLuc(
        String soCMNDDoiTuongTrichLuc, boolean retrieveFromCache)
        throws SystemException {
        Object[] finderArgs = new Object[] { soCMNDDoiTuongTrichLuc };

        Object result = null;

        if (retrieveFromCache) {
            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                    finderArgs, this);
        }

        if (result instanceof YeuCauTrichLuc) {
            YeuCauTrichLuc yeuCauTrichLuc = (YeuCauTrichLuc) result;

            if (!Validator.equals(soCMNDDoiTuongTrichLuc,
                        yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc())) {
                result = null;
            }
        }

        if (result == null) {
            StringBundler query = new StringBundler(3);

            query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                List<YeuCauTrichLuc> list = q.list();

                if (list.isEmpty()) {
                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                        finderArgs, list);
                } else {
                    if ((list.size() > 1) && _log.isWarnEnabled()) {
                        _log.warn(
                            "YeuCauTrichLucPersistenceImpl.fetchBySoCMNDDoiTuongTrichLuc(String, boolean) with parameters (" +
                            StringUtil.merge(finderArgs) +
                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
                    }

                    YeuCauTrichLuc yeuCauTrichLuc = list.get(0);

                    result = yeuCauTrichLuc;

                    cacheResult(yeuCauTrichLuc);

                    if ((yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc() == null) ||
                            !yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc()
                                               .equals(soCMNDDoiTuongTrichLuc)) {
                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                            finderArgs, yeuCauTrichLuc);
                    }
                }
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                    finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        if (result instanceof List<?>) {
            return null;
        } else {
            return (YeuCauTrichLuc) result;
        }
    }

    /**
     * Removes the yeu cau trich luc where soCMNDDoiTuongTrichLuc = &#63; from the database.
     *
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @return the yeu cau trich luc that was removed
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc removeBySoCMNDDoiTuongTrichLuc(
        String soCMNDDoiTuongTrichLuc)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = findBySoCMNDDoiTuongTrichLuc(soCMNDDoiTuongTrichLuc);

        return remove(yeuCauTrichLuc);
    }

    /**
     * Returns the number of yeu cau trich lucs where soCMNDDoiTuongTrichLuc = &#63;.
     *
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @return the number of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countBySoCMNDDoiTuongTrichLuc(String soCMNDDoiTuongTrichLuc)
        throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC;

        Object[] finderArgs = new Object[] { soCMNDDoiTuongTrichLuc };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(2);

            query.append(_SQL_COUNT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SOCMNDDOITUONGTRICHLUC_SOCMNDDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns the yeu cau trich luc where soDinhDanhCaNhanDoiTuongTrichLuc = &#63; or throws a {@link qldc.pm.tiensu.NoSuchYeuCauTrichLucException} if it could not be found.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @return the matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySoDinhDanhCaNhanDoiTuongTrichLuc(
        String soDinhDanhCaNhanDoiTuongTrichLuc)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySoDinhDanhCaNhanDoiTuongTrichLuc(soDinhDanhCaNhanDoiTuongTrichLuc);

        if (yeuCauTrichLuc == null) {
            StringBundler msg = new StringBundler(4);

            msg.append(_NO_SUCH_ENTITY_WITH_KEY);

            msg.append("soDinhDanhCaNhanDoiTuongTrichLuc=");
            msg.append(soDinhDanhCaNhanDoiTuongTrichLuc);

            msg.append(StringPool.CLOSE_CURLY_BRACE);

            if (_log.isWarnEnabled()) {
                _log.warn(msg.toString());
            }

            throw new NoSuchYeuCauTrichLucException(msg.toString());
        }

        return yeuCauTrichLuc;
    }

    /**
     * Returns the yeu cau trich luc where soDinhDanhCaNhanDoiTuongTrichLuc = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @return the matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySoDinhDanhCaNhanDoiTuongTrichLuc(
        String soDinhDanhCaNhanDoiTuongTrichLuc) throws SystemException {
        return fetchBySoDinhDanhCaNhanDoiTuongTrichLuc(soDinhDanhCaNhanDoiTuongTrichLuc,
            true);
    }

    /**
     * Returns the yeu cau trich luc where soDinhDanhCaNhanDoiTuongTrichLuc = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param retrieveFromCache whether to use the finder cache
     * @return the matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySoDinhDanhCaNhanDoiTuongTrichLuc(
        String soDinhDanhCaNhanDoiTuongTrichLuc, boolean retrieveFromCache)
        throws SystemException {
        Object[] finderArgs = new Object[] { soDinhDanhCaNhanDoiTuongTrichLuc };

        Object result = null;

        if (retrieveFromCache) {
            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                    finderArgs, this);
        }

        if (result instanceof YeuCauTrichLuc) {
            YeuCauTrichLuc yeuCauTrichLuc = (YeuCauTrichLuc) result;

            if (!Validator.equals(soDinhDanhCaNhanDoiTuongTrichLuc,
                        yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc())) {
                result = null;
            }
        }

        if (result == null) {
            StringBundler query = new StringBundler(3);

            query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                List<YeuCauTrichLuc> list = q.list();

                if (list.isEmpty()) {
                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                        finderArgs, list);
                } else {
                    if ((list.size() > 1) && _log.isWarnEnabled()) {
                        _log.warn(
                            "YeuCauTrichLucPersistenceImpl.fetchBySoDinhDanhCaNhanDoiTuongTrichLuc(String, boolean) with parameters (" +
                            StringUtil.merge(finderArgs) +
                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
                    }

                    YeuCauTrichLuc yeuCauTrichLuc = list.get(0);

                    result = yeuCauTrichLuc;

                    cacheResult(yeuCauTrichLuc);

                    if ((yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc() == null) ||
                            !yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc()
                                               .equals(soDinhDanhCaNhanDoiTuongTrichLuc)) {
                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                            finderArgs, yeuCauTrichLuc);
                    }
                }
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                    finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        if (result instanceof List<?>) {
            return null;
        } else {
            return (YeuCauTrichLuc) result;
        }
    }

    /**
     * Removes the yeu cau trich luc where soDinhDanhCaNhanDoiTuongTrichLuc = &#63; from the database.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @return the yeu cau trich luc that was removed
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc removeBySoDinhDanhCaNhanDoiTuongTrichLuc(
        String soDinhDanhCaNhanDoiTuongTrichLuc)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = findBySoDinhDanhCaNhanDoiTuongTrichLuc(soDinhDanhCaNhanDoiTuongTrichLuc);

        return remove(yeuCauTrichLuc);
    }

    /**
     * Returns the number of yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc = &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @return the number of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countBySoDinhDanhCaNhanDoiTuongTrichLuc(
        String soDinhDanhCaNhanDoiTuongTrichLuc) throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC;

        Object[] finderArgs = new Object[] { soDinhDanhCaNhanDoiTuongTrichLuc };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(2);

            query.append(_SQL_COUNT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SODINHDANHCANHANDOITUONGTRICHLUC_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns all the yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @return the matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        return findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(soDinhDanhCaNhanDoiTuongTrichLuc,
            hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
            hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
    }

    /**
     * Returns a range of all the yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @return the range of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        int start, int end) throws SystemException {
        return findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(soDinhDanhCaNhanDoiTuongTrichLuc,
            hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
            hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc, start, end,
            null);
    }

    /**
     * Returns an ordered range of all the yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        int start, int end, OrderByComparator orderByComparator)
        throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK;
        finderArgs = new Object[] {
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc,
                
                start, end, orderByComparator
            };

        List<YeuCauTrichLuc> list = (List<YeuCauTrichLuc>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (YeuCauTrichLuc yeuCauTrichLuc : list) {
                if (!StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc(),
                            soDinhDanhCaNhanDoiTuongTrichLuc,
                            CharPool.UNDERLINE, CharPool.PERCENT,
                            CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getHoVaTenNguoiYeuCauTrichLuc(),
                            hoVaTenNguoiYeuCauTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc(),
                            soCMNDDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getHoVaTenDoiTuongTrichLuc(),
                            hoVaTenDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoSoHoKhauDoiTuongTrichLuc(),
                            soSoHoKhauDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)) {
                    list = null;

                    break;
                }
            }
        }

        if (list == null) {
            StringBundler query = null;

            if (orderByComparator != null) {
                query = new StringBundler(7 +
                        (orderByComparator.getOrderByFields().length * 3));
            } else {
                query = new StringBundler(7);
            }

            query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

            if (hoVaTenNguoiYeuCauTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_1);
            } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_3);
            } else {
                bindHoVaTenNguoiYeuCauTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_2);
            }

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenDoiTuongTrichLuc = false;

            if (hoVaTenDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_1);
            } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_3);
            } else {
                bindHoVaTenDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_2);
            }

            boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

            if (soSoHoKhauDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_1);
            } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_3);
            } else {
                bindSoSoHoKhauDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_2);
            }

            if (orderByComparator != null) {
                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);
            } else
             if (pagination) {
                query.append(YeuCauTrichLucModelImpl.ORDER_BY_JPQL);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                if (bindHoVaTenNguoiYeuCauTrichLuc) {
                    qPos.add(hoVaTenNguoiYeuCauTrichLuc);
                }

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                if (bindHoVaTenDoiTuongTrichLuc) {
                    qPos.add(hoVaTenDoiTuongTrichLuc);
                }

                if (bindSoSoHoKhauDoiTuongTrichLuc) {
                    qPos.add(soSoHoKhauDoiTuongTrichLuc);
                }

                if (!pagination) {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<YeuCauTrichLuc>(list);
                } else {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Returns the first yeu cau trich luc in the ordered set where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_First(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_First(soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                orderByComparator);

        if (yeuCauTrichLuc != null) {
            return yeuCauTrichLuc;
        }

        StringBundler msg = new StringBundler(12);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("soDinhDanhCaNhanDoiTuongTrichLuc=");
        msg.append(soDinhDanhCaNhanDoiTuongTrichLuc);

        msg.append(", hoVaTenNguoiYeuCauTrichLuc=");
        msg.append(hoVaTenNguoiYeuCauTrichLuc);

        msg.append(", soCMNDDoiTuongTrichLuc=");
        msg.append(soCMNDDoiTuongTrichLuc);

        msg.append(", hoVaTenDoiTuongTrichLuc=");
        msg.append(hoVaTenDoiTuongTrichLuc);

        msg.append(", soSoHoKhauDoiTuongTrichLuc=");
        msg.append(soSoHoKhauDoiTuongTrichLuc);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchYeuCauTrichLucException(msg.toString());
    }

    /**
     * Returns the first yeu cau trich luc in the ordered set where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_First(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator) throws SystemException {
        List<YeuCauTrichLuc> list = findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc, 0, 1,
                orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the last yeu cau trich luc in the ordered set where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_Last(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_Last(soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                orderByComparator);

        if (yeuCauTrichLuc != null) {
            return yeuCauTrichLuc;
        }

        StringBundler msg = new StringBundler(12);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("soDinhDanhCaNhanDoiTuongTrichLuc=");
        msg.append(soDinhDanhCaNhanDoiTuongTrichLuc);

        msg.append(", hoVaTenNguoiYeuCauTrichLuc=");
        msg.append(hoVaTenNguoiYeuCauTrichLuc);

        msg.append(", soCMNDDoiTuongTrichLuc=");
        msg.append(soCMNDDoiTuongTrichLuc);

        msg.append(", hoVaTenDoiTuongTrichLuc=");
        msg.append(hoVaTenDoiTuongTrichLuc);

        msg.append(", soSoHoKhauDoiTuongTrichLuc=");
        msg.append(soSoHoKhauDoiTuongTrichLuc);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchYeuCauTrichLucException(msg.toString());
    }

    /**
     * Returns the last yeu cau trich luc in the ordered set where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_Last(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator) throws SystemException {
        int count = countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc);

        if (count == 0) {
            return null;
        }

        List<YeuCauTrichLuc> list = findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc, count - 1,
                count, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the yeu cau trich lucs before and after the current yeu cau trich luc in the ordered set where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param yeuCauTrichLucId the primary key of the current yeu cau trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the previous, current, and next yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc[] findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_PrevAndNext(
        long yeuCauTrichLucId, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = findByPrimaryKey(yeuCauTrichLucId);

        Session session = null;

        try {
            session = openSession();

            YeuCauTrichLuc[] array = new YeuCauTrichLucImpl[3];

            array[0] = getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_PrevAndNext(session,
                    yeuCauTrichLuc, soDinhDanhCaNhanDoiTuongTrichLuc,
                    hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                    hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                    orderByComparator, true);

            array[1] = yeuCauTrichLuc;

            array[2] = getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_PrevAndNext(session,
                    yeuCauTrichLuc, soDinhDanhCaNhanDoiTuongTrichLuc,
                    hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                    hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                    orderByComparator, false);

            return array;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    protected YeuCauTrichLuc getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_PrevAndNext(
        Session session, YeuCauTrichLuc yeuCauTrichLuc,
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator, boolean previous) {
        StringBundler query = null;

        if (orderByComparator != null) {
            query = new StringBundler(6 +
                    (orderByComparator.getOrderByFields().length * 6));
        } else {
            query = new StringBundler(3);
        }

        query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

        boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

        if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_1);
        } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_3);
        } else {
            bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_2);
        }

        boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

        if (hoVaTenNguoiYeuCauTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_1);
        } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_3);
        } else {
            bindHoVaTenNguoiYeuCauTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_2);
        }

        boolean bindSoCMNDDoiTuongTrichLuc = false;

        if (soCMNDDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_1);
        } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_3);
        } else {
            bindSoCMNDDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_2);
        }

        boolean bindHoVaTenDoiTuongTrichLuc = false;

        if (hoVaTenDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_1);
        } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_3);
        } else {
            bindHoVaTenDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_2);
        }

        boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

        if (soSoHoKhauDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_1);
        } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_3);
        } else {
            bindSoSoHoKhauDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_2);
        }

        if (orderByComparator != null) {
            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

            if (orderByConditionFields.length > 0) {
                query.append(WHERE_AND);
            }

            for (int i = 0; i < orderByConditionFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByConditionFields[i]);

                if ((i + 1) < orderByConditionFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
                    } else {
                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN);
                    } else {
                        query.append(WHERE_LESSER_THAN);
                    }
                }
            }

            query.append(ORDER_BY_CLAUSE);

            String[] orderByFields = orderByComparator.getOrderByFields();

            for (int i = 0; i < orderByFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByFields[i]);

                if ((i + 1) < orderByFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC_HAS_NEXT);
                    } else {
                        query.append(ORDER_BY_DESC_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC);
                    } else {
                        query.append(ORDER_BY_DESC);
                    }
                }
            }
        } else {
            query.append(YeuCauTrichLucModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Query q = session.createQuery(sql);

        q.setFirstResult(0);
        q.setMaxResults(2);

        QueryPos qPos = QueryPos.getInstance(q);

        if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
            qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
        }

        if (bindHoVaTenNguoiYeuCauTrichLuc) {
            qPos.add(hoVaTenNguoiYeuCauTrichLuc);
        }

        if (bindSoCMNDDoiTuongTrichLuc) {
            qPos.add(soCMNDDoiTuongTrichLuc);
        }

        if (bindHoVaTenDoiTuongTrichLuc) {
            qPos.add(hoVaTenDoiTuongTrichLuc);
        }

        if (bindSoSoHoKhauDoiTuongTrichLuc) {
            qPos.add(soSoHoKhauDoiTuongTrichLuc);
        }

        if (orderByComparator != null) {
            Object[] values = orderByComparator.getOrderByConditionValues(yeuCauTrichLuc);

            for (Object value : values) {
                qPos.add(value);
            }
        }

        List<YeuCauTrichLuc> list = q.list();

        if (list.size() == 2) {
            return list.get(1);
        } else {
            return null;
        }
    }

    /**
     * Removes all the yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63; from the database.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        for (YeuCauTrichLuc yeuCauTrichLuc : findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, null)) {
            remove(yeuCauTrichLuc);
        }
    }

    /**
     * Returns the number of yeu cau trich lucs where soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @return the number of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK(
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK;

        Object[] finderArgs = new Object[] {
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc
            };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(6);

            query.append(_SQL_COUNT_YEUCAUTRICHLUC_WHERE);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

            if (hoVaTenNguoiYeuCauTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_1);
            } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_3);
            } else {
                bindHoVaTenNguoiYeuCauTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENNGUOIYEUCAUTRICHLUC_2);
            }

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOCMNDDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenDoiTuongTrichLuc = false;

            if (hoVaTenDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_1);
            } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_3);
            } else {
                bindHoVaTenDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_HOVATENDOITUONGTRICHLUC_2);
            }

            boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

            if (soSoHoKhauDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_1);
            } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_3);
            } else {
                bindSoSoHoKhauDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_SOSOHOKHAUDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                if (bindHoVaTenNguoiYeuCauTrichLuc) {
                    qPos.add(hoVaTenNguoiYeuCauTrichLuc);
                }

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                if (bindHoVaTenDoiTuongTrichLuc) {
                    qPos.add(hoVaTenDoiTuongTrichLuc);
                }

                if (bindSoSoHoKhauDoiTuongTrichLuc) {
                    qPos.add(soSoHoKhauDoiTuongTrichLuc);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns all the yeu cau trich lucs where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @return the matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        return findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(daTrichLuc,
            soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
            soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
            soSoHoKhauDoiTuongTrichLuc, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
            null);
    }

    /**
     * Returns a range of all the yeu cau trich lucs where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @return the range of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        int start, int end) throws SystemException {
        return findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(daTrichLuc,
            soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
            soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
            soSoHoKhauDoiTuongTrichLuc, start, end, null);
    }

    /**
     * Returns an ordered range of all the yeu cau trich lucs where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        int start, int end, OrderByComparator orderByComparator)
        throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI;
        finderArgs = new Object[] {
                daTrichLuc, soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                
                start, end, orderByComparator
            };

        List<YeuCauTrichLuc> list = (List<YeuCauTrichLuc>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (YeuCauTrichLuc yeuCauTrichLuc : list) {
                if (!Validator.equals(daTrichLuc, yeuCauTrichLuc.getDaTrichLuc()) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc(),
                            soDinhDanhCaNhanDoiTuongTrichLuc,
                            CharPool.UNDERLINE, CharPool.PERCENT,
                            CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getHoVaTenNguoiYeuCauTrichLuc(),
                            hoVaTenNguoiYeuCauTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc(),
                            soCMNDDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getHoVaTenDoiTuongTrichLuc(),
                            hoVaTenDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true) ||
                        !StringUtil.wildcardMatches(
                            yeuCauTrichLuc.getSoSoHoKhauDoiTuongTrichLuc(),
                            soSoHoKhauDoiTuongTrichLuc, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)) {
                    list = null;

                    break;
                }
            }
        }

        if (list == null) {
            StringBundler query = null;

            if (orderByComparator != null) {
                query = new StringBundler(8 +
                        (orderByComparator.getOrderByFields().length * 3));
            } else {
                query = new StringBundler(8);
            }

            query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_DATRICHLUC_2);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

            if (hoVaTenNguoiYeuCauTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_1);
            } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_3);
            } else {
                bindHoVaTenNguoiYeuCauTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_2);
            }

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenDoiTuongTrichLuc = false;

            if (hoVaTenDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_1);
            } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_3);
            } else {
                bindHoVaTenDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_2);
            }

            boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

            if (soSoHoKhauDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_1);
            } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_3);
            } else {
                bindSoSoHoKhauDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_2);
            }

            if (orderByComparator != null) {
                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);
            } else
             if (pagination) {
                query.append(YeuCauTrichLucModelImpl.ORDER_BY_JPQL);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(daTrichLuc.booleanValue());

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                if (bindHoVaTenNguoiYeuCauTrichLuc) {
                    qPos.add(hoVaTenNguoiYeuCauTrichLuc);
                }

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                if (bindHoVaTenDoiTuongTrichLuc) {
                    qPos.add(hoVaTenDoiTuongTrichLuc);
                }

                if (bindSoSoHoKhauDoiTuongTrichLuc) {
                    qPos.add(soSoHoKhauDoiTuongTrichLuc);
                }

                if (!pagination) {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<YeuCauTrichLuc>(list);
                } else {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Returns the first yeu cau trich luc in the ordered set where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_First(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_First(daTrichLuc,
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc, orderByComparator);

        if (yeuCauTrichLuc != null) {
            return yeuCauTrichLuc;
        }

        StringBundler msg = new StringBundler(14);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("daTrichLuc=");
        msg.append(daTrichLuc);

        msg.append(", soDinhDanhCaNhanDoiTuongTrichLuc=");
        msg.append(soDinhDanhCaNhanDoiTuongTrichLuc);

        msg.append(", hoVaTenNguoiYeuCauTrichLuc=");
        msg.append(hoVaTenNguoiYeuCauTrichLuc);

        msg.append(", soCMNDDoiTuongTrichLuc=");
        msg.append(soCMNDDoiTuongTrichLuc);

        msg.append(", hoVaTenDoiTuongTrichLuc=");
        msg.append(hoVaTenDoiTuongTrichLuc);

        msg.append(", soSoHoKhauDoiTuongTrichLuc=");
        msg.append(soSoHoKhauDoiTuongTrichLuc);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchYeuCauTrichLucException(msg.toString());
    }

    /**
     * Returns the first yeu cau trich luc in the ordered set where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_First(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator) throws SystemException {
        List<YeuCauTrichLuc> list = findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(daTrichLuc,
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc, 0, 1, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the last yeu cau trich luc in the ordered set where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_Last(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_Last(daTrichLuc,
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc, orderByComparator);

        if (yeuCauTrichLuc != null) {
            return yeuCauTrichLuc;
        }

        StringBundler msg = new StringBundler(14);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("daTrichLuc=");
        msg.append(daTrichLuc);

        msg.append(", soDinhDanhCaNhanDoiTuongTrichLuc=");
        msg.append(soDinhDanhCaNhanDoiTuongTrichLuc);

        msg.append(", hoVaTenNguoiYeuCauTrichLuc=");
        msg.append(hoVaTenNguoiYeuCauTrichLuc);

        msg.append(", soCMNDDoiTuongTrichLuc=");
        msg.append(soCMNDDoiTuongTrichLuc);

        msg.append(", hoVaTenDoiTuongTrichLuc=");
        msg.append(hoVaTenDoiTuongTrichLuc);

        msg.append(", soSoHoKhauDoiTuongTrichLuc=");
        msg.append(soSoHoKhauDoiTuongTrichLuc);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchYeuCauTrichLucException(msg.toString());
    }

    /**
     * Returns the last yeu cau trich luc in the ordered set where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching yeu cau trich luc, or <code>null</code> if a matching yeu cau trich luc could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_Last(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator) throws SystemException {
        int count = countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(daTrichLuc,
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc);

        if (count == 0) {
            return null;
        }

        List<YeuCauTrichLuc> list = findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(daTrichLuc,
                soDinhDanhCaNhanDoiTuongTrichLuc, hoVaTenNguoiYeuCauTrichLuc,
                soCMNDDoiTuongTrichLuc, hoVaTenDoiTuongTrichLuc,
                soSoHoKhauDoiTuongTrichLuc, count - 1, count, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the yeu cau trich lucs before and after the current yeu cau trich luc in the ordered set where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param yeuCauTrichLucId the primary key of the current yeu cau trich luc
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the previous, current, and next yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc[] findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_PrevAndNext(
        long yeuCauTrichLucId, Boolean daTrichLuc,
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = findByPrimaryKey(yeuCauTrichLucId);

        Session session = null;

        try {
            session = openSession();

            YeuCauTrichLuc[] array = new YeuCauTrichLucImpl[3];

            array[0] = getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_PrevAndNext(session,
                    yeuCauTrichLuc, daTrichLuc,
                    soDinhDanhCaNhanDoiTuongTrichLuc,
                    hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                    hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                    orderByComparator, true);

            array[1] = yeuCauTrichLuc;

            array[2] = getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_PrevAndNext(session,
                    yeuCauTrichLuc, daTrichLuc,
                    soDinhDanhCaNhanDoiTuongTrichLuc,
                    hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                    hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                    orderByComparator, false);

            return array;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    protected YeuCauTrichLuc getBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_PrevAndNext(
        Session session, YeuCauTrichLuc yeuCauTrichLuc, Boolean daTrichLuc,
        String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc,
        OrderByComparator orderByComparator, boolean previous) {
        StringBundler query = null;

        if (orderByComparator != null) {
            query = new StringBundler(6 +
                    (orderByComparator.getOrderByFields().length * 6));
        } else {
            query = new StringBundler(3);
        }

        query.append(_SQL_SELECT_YEUCAUTRICHLUC_WHERE);

        query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_DATRICHLUC_2);

        boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

        if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_1);
        } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_3);
        } else {
            bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_2);
        }

        boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

        if (hoVaTenNguoiYeuCauTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_1);
        } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_3);
        } else {
            bindHoVaTenNguoiYeuCauTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_2);
        }

        boolean bindSoCMNDDoiTuongTrichLuc = false;

        if (soCMNDDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_1);
        } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_3);
        } else {
            bindSoCMNDDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_2);
        }

        boolean bindHoVaTenDoiTuongTrichLuc = false;

        if (hoVaTenDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_1);
        } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_3);
        } else {
            bindHoVaTenDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_2);
        }

        boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

        if (soSoHoKhauDoiTuongTrichLuc == null) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_1);
        } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_3);
        } else {
            bindSoSoHoKhauDoiTuongTrichLuc = true;

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_2);
        }

        if (orderByComparator != null) {
            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

            if (orderByConditionFields.length > 0) {
                query.append(WHERE_AND);
            }

            for (int i = 0; i < orderByConditionFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByConditionFields[i]);

                if ((i + 1) < orderByConditionFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
                    } else {
                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN);
                    } else {
                        query.append(WHERE_LESSER_THAN);
                    }
                }
            }

            query.append(ORDER_BY_CLAUSE);

            String[] orderByFields = orderByComparator.getOrderByFields();

            for (int i = 0; i < orderByFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByFields[i]);

                if ((i + 1) < orderByFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC_HAS_NEXT);
                    } else {
                        query.append(ORDER_BY_DESC_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC);
                    } else {
                        query.append(ORDER_BY_DESC);
                    }
                }
            }
        } else {
            query.append(YeuCauTrichLucModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Query q = session.createQuery(sql);

        q.setFirstResult(0);
        q.setMaxResults(2);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(daTrichLuc.booleanValue());

        if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
            qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
        }

        if (bindHoVaTenNguoiYeuCauTrichLuc) {
            qPos.add(hoVaTenNguoiYeuCauTrichLuc);
        }

        if (bindSoCMNDDoiTuongTrichLuc) {
            qPos.add(soCMNDDoiTuongTrichLuc);
        }

        if (bindHoVaTenDoiTuongTrichLuc) {
            qPos.add(hoVaTenDoiTuongTrichLuc);
        }

        if (bindSoSoHoKhauDoiTuongTrichLuc) {
            qPos.add(soSoHoKhauDoiTuongTrichLuc);
        }

        if (orderByComparator != null) {
            Object[] values = orderByComparator.getOrderByConditionValues(yeuCauTrichLuc);

            for (Object value : values) {
                qPos.add(value);
            }
        }

        List<YeuCauTrichLuc> list = q.list();

        if (list.size() == 2) {
            return list.get(1);
        } else {
            return null;
        }
    }

    /**
     * Removes all the yeu cau trich lucs where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63; from the database.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        for (YeuCauTrichLuc yeuCauTrichLuc : findBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
                daTrichLuc, soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc,
                QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
            remove(yeuCauTrichLuc);
        }
    }

    /**
     * Returns the number of yeu cau trich lucs where daTrichLuc = &#63; and soDinhDanhCaNhanDoiTuongTrichLuc LIKE &#63; and hoVaTenNguoiYeuCauTrichLuc LIKE &#63; and soCMNDDoiTuongTrichLuc LIKE &#63; and hoVaTenDoiTuongTrichLuc LIKE &#63; and soSoHoKhauDoiTuongTrichLuc LIKE &#63;.
     *
     * @param daTrichLuc the da trich luc
     * @param soDinhDanhCaNhanDoiTuongTrichLuc the so dinh danh ca nhan doi tuong trich luc
     * @param hoVaTenNguoiYeuCauTrichLuc the ho va ten nguoi yeu cau trich luc
     * @param soCMNDDoiTuongTrichLuc the so c m n d doi tuong trich luc
     * @param hoVaTenDoiTuongTrichLuc the ho va ten doi tuong trich luc
     * @param soSoHoKhauDoiTuongTrichLuc the so so ho khau doi tuong trich luc
     * @return the number of matching yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countBySDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI(
        Boolean daTrichLuc, String soDinhDanhCaNhanDoiTuongTrichLuc,
        String hoVaTenNguoiYeuCauTrichLuc, String soCMNDDoiTuongTrichLuc,
        String hoVaTenDoiTuongTrichLuc, String soSoHoKhauDoiTuongTrichLuc)
        throws SystemException {
        FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI;

        Object[] finderArgs = new Object[] {
                daTrichLuc, soDinhDanhCaNhanDoiTuongTrichLuc,
                hoVaTenNguoiYeuCauTrichLuc, soCMNDDoiTuongTrichLuc,
                hoVaTenDoiTuongTrichLuc, soSoHoKhauDoiTuongTrichLuc
            };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(7);

            query.append(_SQL_COUNT_YEUCAUTRICHLUC_WHERE);

            query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_DATRICHLUC_2);

            boolean bindSoDinhDanhCaNhanDoiTuongTrichLuc = false;

            if (soDinhDanhCaNhanDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_1);
            } else if (soDinhDanhCaNhanDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_3);
            } else {
                bindSoDinhDanhCaNhanDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SODINHDANHCANHANDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenNguoiYeuCauTrichLuc = false;

            if (hoVaTenNguoiYeuCauTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_1);
            } else if (hoVaTenNguoiYeuCauTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_3);
            } else {
                bindHoVaTenNguoiYeuCauTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENNGUOIYEUCAUTRICHLUC_2);
            }

            boolean bindSoCMNDDoiTuongTrichLuc = false;

            if (soCMNDDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_1);
            } else if (soCMNDDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_3);
            } else {
                bindSoCMNDDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOCMNDDOITUONGTRICHLUC_2);
            }

            boolean bindHoVaTenDoiTuongTrichLuc = false;

            if (hoVaTenDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_1);
            } else if (hoVaTenDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_3);
            } else {
                bindHoVaTenDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_HOVATENDOITUONGTRICHLUC_2);
            }

            boolean bindSoSoHoKhauDoiTuongTrichLuc = false;

            if (soSoHoKhauDoiTuongTrichLuc == null) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_1);
            } else if (soSoHoKhauDoiTuongTrichLuc.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_3);
            } else {
                bindSoSoHoKhauDoiTuongTrichLuc = true;

                query.append(_FINDER_COLUMN_SDDCN_NYCTL_CQ_CMND_DTTL_SHK_TRANGTHAI_SOSOHOKHAUDOITUONGTRICHLUC_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(daTrichLuc.booleanValue());

                if (bindSoDinhDanhCaNhanDoiTuongTrichLuc) {
                    qPos.add(soDinhDanhCaNhanDoiTuongTrichLuc);
                }

                if (bindHoVaTenNguoiYeuCauTrichLuc) {
                    qPos.add(hoVaTenNguoiYeuCauTrichLuc);
                }

                if (bindSoCMNDDoiTuongTrichLuc) {
                    qPos.add(soCMNDDoiTuongTrichLuc);
                }

                if (bindHoVaTenDoiTuongTrichLuc) {
                    qPos.add(hoVaTenDoiTuongTrichLuc);
                }

                if (bindSoSoHoKhauDoiTuongTrichLuc) {
                    qPos.add(soSoHoKhauDoiTuongTrichLuc);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Caches the yeu cau trich luc in the entity cache if it is enabled.
     *
     * @param yeuCauTrichLuc the yeu cau trich luc
     */
    @Override
    public void cacheResult(YeuCauTrichLuc yeuCauTrichLuc) {
        EntityCacheUtil.putResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, yeuCauTrichLuc.getPrimaryKey(),
            yeuCauTrichLuc);

        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
            new Object[] { yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc() },
            yeuCauTrichLuc);

        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
            new Object[] { yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc() },
            yeuCauTrichLuc);

        yeuCauTrichLuc.resetOriginalValues();
    }

    /**
     * Caches the yeu cau trich lucs in the entity cache if it is enabled.
     *
     * @param yeuCauTrichLucs the yeu cau trich lucs
     */
    @Override
    public void cacheResult(List<YeuCauTrichLuc> yeuCauTrichLucs) {
        for (YeuCauTrichLuc yeuCauTrichLuc : yeuCauTrichLucs) {
            if (EntityCacheUtil.getResult(
                        YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
                        YeuCauTrichLucImpl.class, yeuCauTrichLuc.getPrimaryKey()) == null) {
                cacheResult(yeuCauTrichLuc);
            } else {
                yeuCauTrichLuc.resetOriginalValues();
            }
        }
    }

    /**
     * Clears the cache for all yeu cau trich lucs.
     *
     * <p>
     * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
     * </p>
     */
    @Override
    public void clearCache() {
        if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
            CacheRegistryUtil.clear(YeuCauTrichLucImpl.class.getName());
        }

        EntityCacheUtil.clearCache(YeuCauTrichLucImpl.class.getName());

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    /**
     * Clears the cache for the yeu cau trich luc.
     *
     * <p>
     * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
     * </p>
     */
    @Override
    public void clearCache(YeuCauTrichLuc yeuCauTrichLuc) {
        EntityCacheUtil.removeResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, yeuCauTrichLuc.getPrimaryKey());

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

        clearUniqueFindersCache(yeuCauTrichLuc);
    }

    @Override
    public void clearCache(List<YeuCauTrichLuc> yeuCauTrichLucs) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

        for (YeuCauTrichLuc yeuCauTrichLuc : yeuCauTrichLucs) {
            EntityCacheUtil.removeResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
                YeuCauTrichLucImpl.class, yeuCauTrichLuc.getPrimaryKey());

            clearUniqueFindersCache(yeuCauTrichLuc);
        }
    }

    protected void cacheUniqueFindersCache(YeuCauTrichLuc yeuCauTrichLuc) {
        if (yeuCauTrichLuc.isNew()) {
            Object[] args = new Object[] {
                    yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc()
                };

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC,
                args, Long.valueOf(1));
            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                args, yeuCauTrichLuc);

            args = new Object[] {
                    yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc()
                };

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                args, Long.valueOf(1));
            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                args, yeuCauTrichLuc);
        } else {
            YeuCauTrichLucModelImpl yeuCauTrichLucModelImpl = (YeuCauTrichLucModelImpl) yeuCauTrichLuc;

            if ((yeuCauTrichLucModelImpl.getColumnBitmask() &
                    FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc()
                    };

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC,
                    args, Long.valueOf(1));
                FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                    args, yeuCauTrichLuc);
            }

            if ((yeuCauTrichLucModelImpl.getColumnBitmask() &
                    FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc()
                    };

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                    args, Long.valueOf(1));
                FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                    args, yeuCauTrichLuc);
            }
        }
    }

    protected void clearUniqueFindersCache(YeuCauTrichLuc yeuCauTrichLuc) {
        YeuCauTrichLucModelImpl yeuCauTrichLucModelImpl = (YeuCauTrichLucModelImpl) yeuCauTrichLuc;

        Object[] args = new Object[] { yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc() };

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC,
            args);
        FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
            args);

        if ((yeuCauTrichLucModelImpl.getColumnBitmask() &
                FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC.getColumnBitmask()) != 0) {
            args = new Object[] {
                    yeuCauTrichLucModelImpl.getOriginalSoCMNDDoiTuongTrichLuc()
                };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SOCMNDDOITUONGTRICHLUC,
                args);
            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SOCMNDDOITUONGTRICHLUC,
                args);
        }

        args = new Object[] { yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc() };

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
            args);
        FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
            args);

        if ((yeuCauTrichLucModelImpl.getColumnBitmask() &
                FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC.getColumnBitmask()) != 0) {
            args = new Object[] {
                    yeuCauTrichLucModelImpl.getOriginalSoDinhDanhCaNhanDoiTuongTrichLuc()
                };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                args);
            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SODINHDANHCANHANDOITUONGTRICHLUC,
                args);
        }
    }

    /**
     * Creates a new yeu cau trich luc with the primary key. Does not add the yeu cau trich luc to the database.
     *
     * @param yeuCauTrichLucId the primary key for the new yeu cau trich luc
     * @return the new yeu cau trich luc
     */
    @Override
    public YeuCauTrichLuc create(long yeuCauTrichLucId) {
        YeuCauTrichLuc yeuCauTrichLuc = new YeuCauTrichLucImpl();

        yeuCauTrichLuc.setNew(true);
        yeuCauTrichLuc.setPrimaryKey(yeuCauTrichLucId);

        return yeuCauTrichLuc;
    }

    /**
     * Removes the yeu cau trich luc with the primary key from the database. Also notifies the appropriate model listeners.
     *
     * @param yeuCauTrichLucId the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc that was removed
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc remove(long yeuCauTrichLucId)
        throws NoSuchYeuCauTrichLucException, SystemException {
        return remove((Serializable) yeuCauTrichLucId);
    }

    /**
     * Removes the yeu cau trich luc with the primary key from the database. Also notifies the appropriate model listeners.
     *
     * @param primaryKey the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc that was removed
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc remove(Serializable primaryKey)
        throws NoSuchYeuCauTrichLucException, SystemException {
        Session session = null;

        try {
            session = openSession();

            YeuCauTrichLuc yeuCauTrichLuc = (YeuCauTrichLuc) session.get(YeuCauTrichLucImpl.class,
                    primaryKey);

            if (yeuCauTrichLuc == null) {
                if (_log.isWarnEnabled()) {
                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
                }

                throw new NoSuchYeuCauTrichLucException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
                    primaryKey);
            }

            return remove(yeuCauTrichLuc);
        } catch (NoSuchYeuCauTrichLucException nsee) {
            throw nsee;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    @Override
    protected YeuCauTrichLuc removeImpl(YeuCauTrichLuc yeuCauTrichLuc)
        throws SystemException {
        yeuCauTrichLuc = toUnwrappedModel(yeuCauTrichLuc);

        Session session = null;

        try {
            session = openSession();

            if (!session.contains(yeuCauTrichLuc)) {
                yeuCauTrichLuc = (YeuCauTrichLuc) session.get(YeuCauTrichLucImpl.class,
                        yeuCauTrichLuc.getPrimaryKeyObj());
            }

            if (yeuCauTrichLuc != null) {
                session.delete(yeuCauTrichLuc);
            }
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }

        if (yeuCauTrichLuc != null) {
            clearCache(yeuCauTrichLuc);
        }

        return yeuCauTrichLuc;
    }

    @Override
    public YeuCauTrichLuc updateImpl(
        qldc.pm.tiensu.model.YeuCauTrichLuc yeuCauTrichLuc)
        throws SystemException {
        yeuCauTrichLuc = toUnwrappedModel(yeuCauTrichLuc);

        boolean isNew = yeuCauTrichLuc.isNew();

        Session session = null;

        try {
            session = openSession();

            if (yeuCauTrichLuc.isNew()) {
                session.save(yeuCauTrichLuc);

                yeuCauTrichLuc.setNew(false);
            } else {
                session.merge(yeuCauTrichLuc);
            }
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

        if (isNew || !YeuCauTrichLucModelImpl.COLUMN_BITMASK_ENABLED) {
            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
        }

        EntityCacheUtil.putResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
            YeuCauTrichLucImpl.class, yeuCauTrichLuc.getPrimaryKey(),
            yeuCauTrichLuc);

        clearUniqueFindersCache(yeuCauTrichLuc);
        cacheUniqueFindersCache(yeuCauTrichLuc);

        return yeuCauTrichLuc;
    }

    protected YeuCauTrichLuc toUnwrappedModel(YeuCauTrichLuc yeuCauTrichLuc) {
        if (yeuCauTrichLuc instanceof YeuCauTrichLucImpl) {
            return yeuCauTrichLuc;
        }

        YeuCauTrichLucImpl yeuCauTrichLucImpl = new YeuCauTrichLucImpl();

        yeuCauTrichLucImpl.setNew(yeuCauTrichLuc.isNew());
        yeuCauTrichLucImpl.setPrimaryKey(yeuCauTrichLuc.getPrimaryKey());

        yeuCauTrichLucImpl.setYeuCauTrichLucId(yeuCauTrichLuc.getYeuCauTrichLucId());
        yeuCauTrichLucImpl.setUserId(yeuCauTrichLuc.getUserId());
        yeuCauTrichLucImpl.setUserName(yeuCauTrichLuc.getUserName());
        yeuCauTrichLucImpl.setCreateDate(yeuCauTrichLuc.getCreateDate());
        yeuCauTrichLucImpl.setModifiedDate(yeuCauTrichLuc.getModifiedDate());
        yeuCauTrichLucImpl.setHoVaTenNguoiYeuCauTrichLuc(yeuCauTrichLuc.getHoVaTenNguoiYeuCauTrichLuc());
        yeuCauTrichLucImpl.setKinhGui(yeuCauTrichLuc.getKinhGui());
        yeuCauTrichLucImpl.setGioiTinh(yeuCauTrichLuc.getGioiTinh());
        yeuCauTrichLucImpl.setQuocTich(yeuCauTrichLuc.getQuocTich());
        yeuCauTrichLucImpl.setDanTocId(yeuCauTrichLuc.getDanTocId());
        yeuCauTrichLucImpl.setSoCMNDDoiTuongTrichLuc(yeuCauTrichLuc.getSoCMNDDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNgayCapCMNDDoiTuongTrichLuc(yeuCauTrichLuc.getNgayCapCMNDDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNoiCapCMNDDoiTuongTrichLuc(yeuCauTrichLuc.getNoiCapCMNDDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setSoHoChieuDoiTuongTrichLuc(yeuCauTrichLuc.getSoHoChieuDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNgayCapHoChieuDoiTuongTrichLuc(yeuCauTrichLuc.getNgayCapHoChieuDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNoiCapHoChieuDoiTuongTrichLuc(yeuCauTrichLuc.getNoiCapHoChieuDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setSoDinhDanhCaNhanDoiTuongTrichLuc(yeuCauTrichLuc.getSoDinhDanhCaNhanDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setHoVaTenDoiTuongTrichLuc(yeuCauTrichLuc.getHoVaTenDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNgaySinhDoiTuongTrichLuc(yeuCauTrichLuc.getNgaySinhDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNoiThuongTruDoiTuongTrichLucTinhId(yeuCauTrichLuc.getNoiThuongTruDoiTuongTrichLucTinhId());
        yeuCauTrichLucImpl.setNoiThuongTruDoiTuongTrichLucQuanHuyenId(yeuCauTrichLuc.getNoiThuongTruDoiTuongTrichLucQuanHuyenId());
        yeuCauTrichLucImpl.setNoiThuongTruDoiTuongTrichLucPhuongXaId(yeuCauTrichLuc.getNoiThuongTruDoiTuongTrichLucPhuongXaId());
        yeuCauTrichLucImpl.setNoiThuongTruDoiTuongTrichLucDiaChi(yeuCauTrichLuc.getNoiThuongTruDoiTuongTrichLucDiaChi());
        yeuCauTrichLucImpl.setSoSoHoKhauDoiTuongTrichLuc(yeuCauTrichLuc.getSoSoHoKhauDoiTuongTrichLuc());
        yeuCauTrichLucImpl.setNoiDungTrichLuc(yeuCauTrichLuc.getNoiDungTrichLuc());
        yeuCauTrichLucImpl.setNgayDeNghiTraTrichLuc(yeuCauTrichLuc.getNgayDeNghiTraTrichLuc());
        yeuCauTrichLucImpl.setNgayLapTrichLuc(yeuCauTrichLuc.getNgayLapTrichLuc());
        yeuCauTrichLucImpl.setChuThich(yeuCauTrichLuc.getChuThich());
        yeuCauTrichLucImpl.setMaYeuCauTrichLuc(yeuCauTrichLuc.getMaYeuCauTrichLuc());
        yeuCauTrichLucImpl.setHoVaTenGoiKhac(yeuCauTrichLuc.getHoVaTenGoiKhac());
        yeuCauTrichLucImpl.setHoVaTenCha(yeuCauTrichLuc.getHoVaTenCha());
        yeuCauTrichLucImpl.setHoVaTenMe(yeuCauTrichLuc.getHoVaTenMe());
        yeuCauTrichLucImpl.setHoTenVoHoacChong(yeuCauTrichLuc.getHoTenVoHoacChong());
        yeuCauTrichLucImpl.setCoQuanYeuCauTrichLuc(yeuCauTrichLuc.getCoQuanYeuCauTrichLuc());
        yeuCauTrichLucImpl.setNoiTamTruDoiTuongTrichLucTinhId(yeuCauTrichLuc.getNoiTamTruDoiTuongTrichLucTinhId());
        yeuCauTrichLucImpl.setNoiTamTruDoiTuongTrichLucQuanHuyenId(yeuCauTrichLuc.getNoiTamTruDoiTuongTrichLucQuanHuyenId());
        yeuCauTrichLucImpl.setNoiTamTruDoiTuongTrichLucPhuongXaId(yeuCauTrichLuc.getNoiTamTruDoiTuongTrichLucPhuongXaId());
        yeuCauTrichLucImpl.setNoiTamTruDoiTuongTrichLucDiaChi(yeuCauTrichLuc.getNoiTamTruDoiTuongTrichLucDiaChi());
        yeuCauTrichLucImpl.setDaTrichLuc(yeuCauTrichLuc.getDaTrichLuc());
        yeuCauTrichLucImpl.setNoiSinh(yeuCauTrichLuc.getNoiSinh());
        yeuCauTrichLucImpl.setNoiSinhTinhId(yeuCauTrichLuc.getNoiSinhTinhId());
        yeuCauTrichLucImpl.setNoiSinhQuanHuyenId(yeuCauTrichLuc.getNoiSinhQuanHuyenId());
        yeuCauTrichLucImpl.setNoiSinhPhuongXaId(yeuCauTrichLuc.getNoiSinhPhuongXaId());

        return yeuCauTrichLucImpl;
    }

    /**
     * Returns the yeu cau trich luc with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
     *
     * @param primaryKey the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findByPrimaryKey(Serializable primaryKey)
        throws NoSuchYeuCauTrichLucException, SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = fetchByPrimaryKey(primaryKey);

        if (yeuCauTrichLuc == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchYeuCauTrichLucException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
                primaryKey);
        }

        return yeuCauTrichLuc;
    }

    /**
     * Returns the yeu cau trich luc with the primary key or throws a {@link qldc.pm.tiensu.NoSuchYeuCauTrichLucException} if it could not be found.
     *
     * @param yeuCauTrichLucId the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc
     * @throws qldc.pm.tiensu.NoSuchYeuCauTrichLucException if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc findByPrimaryKey(long yeuCauTrichLucId)
        throws NoSuchYeuCauTrichLucException, SystemException {
        return findByPrimaryKey((Serializable) yeuCauTrichLucId);
    }

    /**
     * Returns the yeu cau trich luc with the primary key or returns <code>null</code> if it could not be found.
     *
     * @param primaryKey the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc, or <code>null</code> if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchByPrimaryKey(Serializable primaryKey)
        throws SystemException {
        YeuCauTrichLuc yeuCauTrichLuc = (YeuCauTrichLuc) EntityCacheUtil.getResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
                YeuCauTrichLucImpl.class, primaryKey);

        if (yeuCauTrichLuc == _nullYeuCauTrichLuc) {
            return null;
        }

        if (yeuCauTrichLuc == null) {
            Session session = null;

            try {
                session = openSession();

                yeuCauTrichLuc = (YeuCauTrichLuc) session.get(YeuCauTrichLucImpl.class,
                        primaryKey);

                if (yeuCauTrichLuc != null) {
                    cacheResult(yeuCauTrichLuc);
                } else {
                    EntityCacheUtil.putResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
                        YeuCauTrichLucImpl.class, primaryKey,
                        _nullYeuCauTrichLuc);
                }
            } catch (Exception e) {
                EntityCacheUtil.removeResult(YeuCauTrichLucModelImpl.ENTITY_CACHE_ENABLED,
                    YeuCauTrichLucImpl.class, primaryKey);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return yeuCauTrichLuc;
    }

    /**
     * Returns the yeu cau trich luc with the primary key or returns <code>null</code> if it could not be found.
     *
     * @param yeuCauTrichLucId the primary key of the yeu cau trich luc
     * @return the yeu cau trich luc, or <code>null</code> if a yeu cau trich luc with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public YeuCauTrichLuc fetchByPrimaryKey(long yeuCauTrichLucId)
        throws SystemException {
        return fetchByPrimaryKey((Serializable) yeuCauTrichLucId);
    }

    /**
     * Returns all the yeu cau trich lucs.
     *
     * @return the yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findAll() throws SystemException {
        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
    }

    /**
     * Returns a range of all the yeu cau trich lucs.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @return the range of yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findAll(int start, int end)
        throws SystemException {
        return findAll(start, end, null);
    }

    /**
     * Returns an ordered range of all the yeu cau trich lucs.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.YeuCauTrichLucModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param start the lower bound of the range of yeu cau trich lucs
     * @param end the upper bound of the range of yeu cau trich lucs (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<YeuCauTrichLuc> findAll(int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
                (orderByComparator == null)) {
            pagination = false;
            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
            finderArgs = FINDER_ARGS_EMPTY;
        } else {
            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
            finderArgs = new Object[] { start, end, orderByComparator };
        }

        List<YeuCauTrichLuc> list = (List<YeuCauTrichLuc>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if (list == null) {
            StringBundler query = null;
            String sql = null;

            if (orderByComparator != null) {
                query = new StringBundler(2 +
                        (orderByComparator.getOrderByFields().length * 3));

                query.append(_SQL_SELECT_YEUCAUTRICHLUC);

                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);

                sql = query.toString();
            } else {
                sql = _SQL_SELECT_YEUCAUTRICHLUC;

                if (pagination) {
                    sql = sql.concat(YeuCauTrichLucModelImpl.ORDER_BY_JPQL);
                }
            }

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                if (!pagination) {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<YeuCauTrichLuc>(list);
                } else {
                    list = (List<YeuCauTrichLuc>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Removes all the yeu cau trich lucs from the database.
     *
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeAll() throws SystemException {
        for (YeuCauTrichLuc yeuCauTrichLuc : findAll()) {
            remove(yeuCauTrichLuc);
        }
    }

    /**
     * Returns the number of yeu cau trich lucs.
     *
     * @return the number of yeu cau trich lucs
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countAll() throws SystemException {
        Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
                FINDER_ARGS_EMPTY, this);

        if (count == null) {
            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(_SQL_COUNT_YEUCAUTRICHLUC);

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
                    FINDER_ARGS_EMPTY, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
                    FINDER_ARGS_EMPTY);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Initializes the yeu cau trich luc persistence.
     */
    public void afterPropertiesSet() {
        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
                    com.liferay.util.service.ServiceProps.get(
                        "value.object.listener.qldc.pm.tiensu.model.YeuCauTrichLuc")));

        if (listenerClassNames.length > 0) {
            try {
                List<ModelListener<YeuCauTrichLuc>> listenersList = new ArrayList<ModelListener<YeuCauTrichLuc>>();

                for (String listenerClassName : listenerClassNames) {
                    listenersList.add((ModelListener<YeuCauTrichLuc>) InstanceFactory.newInstance(
                            getClassLoader(), listenerClassName));
                }

                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
            } catch (Exception e) {
                _log.error(e);
            }
        }
    }

    public void destroy() {
        EntityCacheUtil.removeCache(YeuCauTrichLucImpl.class.getName());
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }
}
